﻿@model KPIS.GERP.Models.FIM.ChequeBook

@using (Html.BeginForm("Edit", "ChequeBook", FormMethod.Post, new { @class = "form-horizontal" }))
{
    @Html.AntiForgeryToken()

    <div class="block-button-menu-above">
        @Html.ButtonViewAll()
        @Html.ButtonSubmit()
        @Html.ButtonCancel(new { id = Model.ChequeBookId })
    </div>
    
   <div class="alert-error">@Html.ValidationSummary()</div>
    @Html.Partial("_EditorForm")
}

@section scripts
{
    <script>
        var oldStartCheque = parseInt($('#Code').val());
        alert(StartCheque);

        $(document).keyup(function () {
            var StartCheque = parseInt($('#Code').val());
            alert(StartCheque);
            if(oldStartCheque == StartCheque){
            
                $("form").submit(function (e) {
                    e.preventDefault();
                    var currentForm = this;
                    bootbox.confirm(function (result) {
                        if (result) {
                            currentForm.submit();
                        }
                    });
                });
            }
            else{
                alert('รหัสซ้ำ');
            }
        }


        $("#StartChequeNo").attr("disabled", "disabled");
        $("#EndChequeNo").attr("disabled", "disabled");

    </script>
}